<?php
class ConfigLoader {
	
	private $_xml;
	private $_data = array();
	
	public function __construct($front = 'frontend'){
		$this->_xml =  simplexml_load_file( DIR_CONTENT.$front. '/config.xml');
		$this->_xml->children();
		foreach ($this->_xml->children() as $child){
			if($child->getName() == 'modules'){
				foreach($child->children()->children()->children() as $modchild){
					$model = (string)$modchild->getName();
					$model = str_replace("_", "/", $model);
					$template = (string)$modchild->attributes()->template;
					$this->_data[$model]['template'] = $template;
					
					foreach($modchild->children() as $attrchild){
						$attrName = (string)$attrchild->attributes()->name;
						$attrVal = (string)$attrchild->attributes()->value;
						$this->_data[$model]['attributes'][$attrName] = $attrVal;
					}
				}
			}

		}
		
		unset($this->_xml);
	}
	
	public function _set($key , $val){
		if(!isset($this->_data[$key])){
			$this->_data[$key] = $val;
		}
		
	}
	
	public function _get($key){
		if(isset($this->_data[$key])){
			return $this->_data[$key] ;
		}
	
	}
	
}
